<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="../../mdui/css/mdui.min.css">
    <script defer src="../../mdui/js/mdui.min.js"></script>
    <script src="../../js/axios.min.js"></script>
    <script src="../../js/qs.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/vue.js"></script>
    <style>
        a {
            text-decoration: none;
        }
    </style>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-green">
<div class="mdui-container-fluid" id="app">
    <h1 class="mdui-text-color-theme">所有催单</h1>
    <div style="width: auto">
        <table class="mdui-table mdui-table-hoverable">
            <thead>
            <tr>
                <th>编号</th>
                <th>状态</th>
                <th>提交人</th>
                <th>提交时间</th>
                <th>对应报修单</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(u,index) in urgents">
                <td>{{u.id }}</td>
                <td>{{u.status |fmtGenter }}</td>
                <td>{{u.student.name}}</td>
                <td>{{u.createTime}}</td>
                <td><a :href="'detail.html?id=' + u.repairId" @click="check(u.id)"> 查看 </a>

                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script>

    let vm = new Vue({
        el: '#app',
        data: {
            id: '',
            place: '',
            urgents: [],
        },

        created() {
            this.finduurgents();
        },

        filters: {
            fmtGenter(val) {
                if (val == 1) {
                    return "未安排维修维修"
                } else if (val == 2) {
                    return "已安排检修"
                } else if (val == 3) {
                    return "待同意取消"
                } else if (val == 4) {
                    return "已同意取消"
                } else if (val == 5) {
                    return "待验收"
                } else if (val == 5) {
                    return "已验收"
                }
            }
        },
        filters: {
            fmtGenter(val) {
                if (val == 1) {
                    return "未查看"
                } else if (val == 2) {
                    return "已查看"
                } else if (val == 3) {
                    return "待同意取消，"
                } else if (val == 4) {
                    return "已同意取消"
                } else if (val == 5) {
                    return "待验收"
                } else if (val == 5) {
                    return "已验收"
                }
            }
        },
        methods: {
            //查看催单更改状态为2
            check(uid) {
                let _this = this
                axios.get("/urgent/check", {
                    params: {
                        uid: uid,
                    }
                })
                    .then(function (res) {
                        _this.finduurgents();
                    })
            },

            finduurgents() {
                let _this = this;
                axios
                    .get("/urgent/allUrgents")
                    .then(function (res) {
                        _this.urgents = res.data;
                        console.log(res.data)
                    })
            },

        },
    })
</script>
</body>
</html>